/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package kimo.persistence.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author a381u296
 */
@Entity
@Table(name = "raw_product")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "RawProduct.findAll", query = "SELECT r FROM RawProduct r"),
    @NamedQuery(name = "RawProduct.findByRawProductId", query = "SELECT r FROM RawProduct r WHERE r.rawProductId = :rawProductId"),
    @NamedQuery(name = "RawProduct.findByRawProductName", query = "SELECT r FROM RawProduct r WHERE r.rawProductName = :rawProductName")})
public class RawProduct implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "raw_product_id")
    private Integer rawProductId;
    @Basic(optional = false)
    @Column(name = "raw_product_name")
    private String rawProductName;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "productionRawProductId")
    private List<Production> productionList;
    @JoinColumn(name = "raw_product_type_id", referencedColumnName = "raw_product_type_id")
    @ManyToOne(optional = false)
    private RawProductType rawProductTypeId;

    public RawProduct() {
    }

    public RawProduct(Integer rawProductId) {
        this.rawProductId = rawProductId;
    }

    public RawProduct(Integer rawProductId, String rawProductName) {
        this.rawProductId = rawProductId;
        this.rawProductName = rawProductName;
    }

    public Integer getRawProductId() {
        return rawProductId;
    }

    public void setRawProductId(Integer rawProductId) {
        this.rawProductId = rawProductId;
    }

    public String getRawProductName() {
        return rawProductName;
    }

    public void setRawProductName(String rawProductName) {
        this.rawProductName = rawProductName;
    }

    @XmlTransient
    public List<Production> getProductionList() {
        return productionList;
    }

    public void setProductionList(List<Production> productionList) {
        this.productionList = productionList;
    }

    public RawProductType getRawProductTypeId() {
        return rawProductTypeId;
    }

    public void setRawProductTypeId(RawProductType rawProductTypeId) {
        this.rawProductTypeId = rawProductTypeId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (rawProductId != null ? rawProductId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RawProduct)) {
            return false;
        }
        RawProduct other = (RawProduct) object;
        if ((this.rawProductId == null && other.rawProductId != null) || (this.rawProductId != null && !this.rawProductId.equals(other.rawProductId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return rawProductName;
    }
    
}
